package com.wxy.zhuzhoumenu;


import com.ak.zhuzhou.R;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MenuFanAdapter extends BaseAdapter {
	private Context context;
	private JSONArray data ;

	public MenuFanAdapter(Context context , JSONArray data ) {
		this.context = context;
		this.data = data;
	}

	class ViewHolder {
		TextView name;
		ImageView gender;
		ImageView avatar;
		ImageView attention;
		TextView attentionText;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return data.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final ViewHolder viewHolder;
		if (convertView == null) {
			LayoutInflater inflater = LayoutInflater.from(context);
			convertView = inflater.inflate(R.layout.x_menu_fan_list_item,
					null);
			viewHolder = new ViewHolder();
			viewHolder.name = (TextView) convertView
					.findViewById(R.id.menu_fan_name);
			viewHolder.gender = (ImageView) convertView
					.findViewById(R.id.menu_fan_gender);
			viewHolder.avatar = (ImageView) convertView
					.findViewById(R.id.menu_fan_avatar);
			viewHolder.attentionText = (TextView) convertView
					.findViewById(R.id.menu_fan_text);
			viewHolder.attention = (ImageView) convertView
					.findViewById(R.id.menu_fan_attention_image);
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		JSONObject dataitem = data.getJSONObject(position);
		 viewHolder.name.setText(dataitem.getString("userName"));
		 
		 String gender = dataitem.getString("gender");
		 final String str = "BOY";
		 if(gender!=null && gender.equals(str)){
			 viewHolder.gender.setImageResource(R.drawable.iconfont_nan);
		 }

		return convertView;

	}
	
      
    @Override  
    public boolean isEnabled(int position) {  
        return false;  
    }  

}
